package lab02.test17;

public class Test17 {
    public static void main(String[] args) {
        int[] a = new int[]{28,45,73,15,64,76,83,45,91,27};
        int min = a[0];
        int max = a[0];
        int kmin = 0;
        int kmax = 0;
        int j = 0;
        int sum = 0;

        for (j = 0; j <a.length;  j ++){
            if (a[j] > max ){
                max = a[j];
                kmax = j;
            } else if (a[j] < min){
                min = a[j];
                kmin = j;
            }
        }
        System.out.println("最大值："+max+"\t最大值是数组中第"+kmax+"个元素");
        System.out.println("最小值："+min+"\t最小值是数组中第"+kmin+"个元素");

        //for循环的改进（输出总和）
        for (int k = 0;k < a.length;){
        sum += a[k++];
        }
        System.out.println("总和是："+sum);
    }

}
